package ${package.Stereotype}.security.impl;

import ${package.Stereotype}.security.bean.LoginUser;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

/**
 * 缓存操作
 */
@Component
public class CacheServiceImpl {

    /**
     * 获取验证码
     * @param user
     * @return
     */
    @Cacheable(cacheNames = "VerifyCode",key = "#user.clientId")
    public LoginUser getVerifyCode(LoginUser user) {
        return null;
    }

    /**
     * 添加验证码
     * @param user
     */
    @CachePut(cacheNames = "VerifyCode",key = "#user.clientId")
    public LoginUser setVerifyCode(LoginUser user) {
        return user;
    }

    /**
     * 删除缓存验证码信息
     * @param user
     */
    @CacheEvict(cacheNames = "VerifyCode",key = "#user.clientId")
    public void removeVerifyCode(LoginUser user) {

    }

    /**
     * 获取用户token
     * @param userName
     * @return
     */
    @Cacheable(cacheNames = "LoginUser",key = "#userName")
    public LoginUser getLoginUser(String userName) {
        return null;
    }

    /**
     * 添加用户token
     * @param user
     */
    @CachePut(cacheNames = "LoginUser",key = "#user.userName")
    public LoginUser setLoginUser(LoginUser user) {
        return user;
    }

    /**
     * 删除缓存验证码信息
     * @param user
     */
    @CacheEvict(cacheNames = "LoginUser",key = "#user.userName")
    public void removeLoginUser(LoginUser user) {

    }
}
